package cn.iocoder.yudao.module.custom.dal.mysql.industry;


import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.custom.controller.admin.industry.vo.IndustryExportReqVO;
import cn.iocoder.yudao.module.custom.controller.admin.industry.vo.IndustryPageReqVO;
import cn.iocoder.yudao.module.custom.dal.dataobject.industry.IndustryDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 行业分类信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface IndustryMapper extends BaseMapperX<IndustryDO> {

    default PageResult<IndustryDO> selectPage(IndustryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IndustryDO>()
                .eqIfPresent(IndustryDO::getIndustryCode, reqVO.getIndustryCode())
                .eqIfPresent(IndustryDO::getIndustryDesc, reqVO.getIndustryDesc())
                .likeIfPresent(IndustryDO::getIndustryName, reqVO.getIndustryName())
                .eqIfPresent(IndustryDO::getParentCode, reqVO.getParentCode())
                .eqIfPresent(IndustryDO::getPs, reqVO.getPs())
                .orderByDesc(IndustryDO::getId));
    }

    default List<IndustryDO> selectList(IndustryExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<IndustryDO>()
                .eqIfPresent(IndustryDO::getIndustryCode, reqVO.getIndustryCode())
                .eqIfPresent(IndustryDO::getIndustryDesc, reqVO.getIndustryDesc())
                .likeIfPresent(IndustryDO::getIndustryName, reqVO.getIndustryName())
                .eqIfPresent(IndustryDO::getParentCode, reqVO.getParentCode())
                .eqIfPresent(IndustryDO::getPs, reqVO.getPs())
                .orderByDesc(IndustryDO::getId));
    }


    /**
     * 获取当前行业
     * @param industryCode 行业的code
     * @return list
     */
    List<IndustryDO> getSecondaryIndustryList(Integer industryCode);
}
